/**********************************************************************\

 Copyright 2012 Diggory Blake

 This file is part of klip-engine

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.

\**********************************************************************/
#pragma once

#include <functional>

class kSystem;

#include "kbase.h"
#include "kcomponent.h"
#include "kcommon.h"
#include "kewindowoptions.h"
#include "kinput.h"

class kWindow : public kBase {
public:
	virtual kHandle getHandle() = 0;
	virtual kMouseInput* getMouseInput() = 0;
	virtual kKeyboardInput* getKeyboardInput() = 0;

	virtual void close() = 0;
	virtual void destroy() = 0;
	virtual kHandle createGLContext() = 0;
	virtual void deleteGLContext(kHandle context) = 0;
	virtual void activateGLContext(kHandle context) = 0;
	virtual void setOptions(keWindowOptions options) = 0;
	virtual void setSize(const kVec2i& size) = 0;
	virtual void setPos(const kVec2i& pos) = 0;
	virtual void setTitle(const std::tstring& title) = 0;
	virtual void swapGLBuffers() = 0;
	virtual kVec2i getPos() = 0;
	virtual kVec2i getSize() = 0;
	virtual keWindowOptions getOptions() = 0;
	inline void set(const kVec2i& pos, const kVec2i& size, keWindowOptions options) {
		setPos(pos);
		setSize(size);
		setOptions(options);
	}

	kDelegate<void (kWindow*, const kVec2i&)>		onMove;
	kDelegate<void (kWindow*, const kVec2i&)>		onResize;
	kDelegate<void (kWindow*, keWindowOptions)>		onChange;
	kDelegate<void (kWindow*, bool*)>				onClose;
	kDelegate<void (kWindow*, bool*)>				onDestroy;
};

class kSystem : public kComponent {
public:
	virtual unsigned getTime() = 0;
	virtual kWindow* createWindow(const std::tstring& title) = 0;
};
